import { NestFactory } from '@nestjs/core';
import { NestExpressApplication } from '@nestjs/platform-express';
import { join } from 'path';
import { readFileSync } from 'fs';
import { AppModule } from './app.module';
import { TransformInterceptor } from './interceptor/transformInterceptor';
import ValidatePipe from './pipe/validatePipe';
console.log(join(__dirname, './ssl/server.key'));
const httpsOptions = {
  key: readFileSync(join(__dirname, './ssl/server.key')),
  cert: readFileSync(join(__dirname, './ssl/server.crt')),
};
async function bootstrap() {
  const app = await NestFactory.create<NestExpressApplication>(AppModule, {
    httpsOptions,
  });
  app.useGlobalPipes(new ValidatePipe());
  app.useGlobalInterceptors(new TransformInterceptor());
  // app.useGlobalFilters(new ValidateExceptionFilter());
  app.enableCors();
  // app.useStaticAssets(join(__dirname, './publicSource'), {
  //   prefix: '/publicSource',
  // });
  app.useStaticAssets('uploads', { prefix: '/uploads' });
  await app.listen(3000);
}
bootstrap();
